<?php

class Messages {
	
	private static $instance = null;
	
	private $messages = array();
	
	public static $lt = '&lt;'; // symbol: <	
	
	public static $gt = '&gt;'; // symbol: >	
	
	public static $sqrBracketLft = '['; // symbol: [ 
	
	public static $sqrBracketRgt = ']'; // symbol: ]	

	private function __construct(){}
		
	public static function getInstance(){
		if(Messages::$instance == null){
			Messages::$instance = new Messages();
		}
		return Messages::$instance;
	}
	
	public function load($resource){
		if(! file_exists($resource)){
			die('Can not load messages! File "' . $resource .'" does not exists');
		}
		
		$file = fopen($resource, "r") or die('Unable to open file "' . $resource .'"!');
		
		while(! feof($file)){
			$line = fgets($file);
			list($key, $value) = explode('=', $line, 2);
			$this->messages[$key] = chop($value); 
		}
		
		fclose($file);
	}
	
	public function getMessage($key){
		return $this->messages[$key];
	}
	
	
	
	
	
	
	
	
}

?>